package br.com.designless.view.Util;

import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Administrador
 */
public class Util {

    public static void encaminharRequisicao(HttpServletRequest request,
                                            HttpServletResponse response,
                                            String forward) throws ServletException, IOException {

        RequestDispatcher rd = request.getRequestDispatcher(forward);

        rd.forward(request, response);
    }

    public static void mostrarMensagemErro(HttpServletRequest request,
                                           HttpServletResponse response,
                                           String forward,
                                           String... msgsErro) throws ServletException, IOException {

        request.setAttribute("msgsErro", msgsErro);

        encaminharRequisicao(request, response, forward);
    }

    public static void mostrarMensagemSucesso(HttpServletRequest request,
                                              String msgSucesso) {

        request.setAttribute("msgSucesso", msgSucesso);
    }

}